<?php

autoLoader();

$mid 	= ( ( true == isset( $_GET['mid'] ) && true == valStr( $_GET['mid'] ) ) ? $_GET['mid'] : NULL );
$smid 	= ( ( true == isset( $_GET['smid'] ) && true == valStr( $_GET['smid'] ) ) ? $_GET['smid'] : NULL );
?>
<style>
div.left_div {
	float: left;
	margin-left: 20px;
}
div.right_div {
	float: right;
	width: 40%;
}

div.main_border {
	margin:auto;
	width:78%;
	border: 2px;
	border-style: solid;
}
	
@media screen /*--This is for Screen--*/
{
	.btn {
		background-color: #AFAFAF;
		display: block;
	}

	.tble {
		background-color: #E5E5E5;
		border: 1px solid #CD853F;
	}
}
</style>
<div>&nbsp;</div>
<div id="print_area">
	<div class="main_border">
		<div id="main_header" style="text-align: center;">
			<div>SARDAR VALLABHABHAI PATEL CANTONMENT GENETAL HOSPITAL</div>
			<div>Golibar Maidan, Shankar Sheth Road, Pune - 411 001.</div>
			<div><u>Case Paper</u></div>
		</div>
		<hr/>
<?php

	$intPatientId 	= '';
	$strFullName 	= '';
	$strOccipation 	= '';
	$strAddress 	= '';
	$intAge 		= '';
	$strDiagnosis 	= '';
	$strAmount 		= '';

	if( true == isset( $_GET['patient_id'] ) && true == isset( $_GET['case_paper_id'] ) && true == valStr( $_GET['patient_id'] ) && true == valStr( $_GET['case_paper_id'] ) ) {
		$objPatient 	= new Patients();
		$objCasePaper 	= new CasePapers();
		$objDignosis 	= new Diagnosises();
		
		$objPatient 	= $objPatient->fetchPatientsById( $_GET['patient_id'] );
		$objCasePaper 	= $objCasePaper->fetchCasePapersById( $_GET['case_paper_id'] );
		
		if( true == valObj( $objCasePaper, 'BaseCasePapers' ) ) {
			$objDignosis = $objDignosis->fetchDiagnosisesById( $objCasePaper->getDiagnosisId() );
		}
		
		if( true == valObj( $objPatient, 'BasePatients' ) && true == valObj( $objCasePaper, 'BaseCasePapers' ) ) {

			$intPatientId 	= $objPatient->getId();
			$strMiddleName 	= ( true == valStr( $objPatient->getMiddleName() ) && 'NULL' != $objPatient->getMiddleName() ) ? $objPatient->getMiddleName() : '';
			$strFullName 	= $objPatient->getFirstName() . ' ' . $strMiddleName . ' ' . $objPatient->getLastName();
			$strOccipation 	= $objPatient->getOccupaction();
			
			$strAmount = $objCasePaper->getAmountPaid();
			
			$strAddress 	= $objPatient->getAddress();
			$intAge 		= $objPatient->getAge();
			$strDiagnosis 	= ( true == valObj( $objDignosis, 'BaseDiagnosises' ) ) ? $objDignosis->getName() : 'N/A';
			
		}
	}
?>
		<div id="patient_data">
			<div class="left_div">
				<label>Patient Id:-</label><label><?php echo $intPatientId; ?></label>
			</div>
			<div class="right_div">
				Date & Time:- <?php echo date( 'd/m/Y : h:m:s' ); ?>
			</div>
			<div style="clear: both;"></div>
			
			<div>&nbsp;</div>
			<div class="left_div">
				<label>Patient Name:-</label>
				<label><?php echo $strFullName; ?></label>
			</div>
			<div class="right_div">
				<label>Occupation:-</label>
				<label><?php echo ( true == valStr( $strOccipation ) && 'NULL' != $strOccipation ) ? $strOccipation : ''; ?></label>
			</div>
			<div style="clear: both;"></div>
			
			<div>&nbsp;</div>
			<div class="left_div">
				<label>Address:-</label>
				<label><?php echo ( true == valStr( $strAddress ) && 'NULL' != $strAddress ) ? $strAddress : ''; ?></label>
			</div>
			<div class="right_div">
				<label>Age:-</label>
				<label><?php echo ( true == valStr( $intAge ) && 'NULL' != $intAge ) ? $intAge : ''; ?></label>
			</div>
			<div style="clear: both;"></div>
			
			<div>&nbsp;</div>
			<div class="left_div">
				<label>Diagnosis:-</label>
				<label><?php echo ( true == valStr( $strDiagnosis ) && 'NULL' != $strDiagnosis ) ? $strDiagnosis : ''; ?></label>
			</div>
			<div class="right_div">
				<label>Payment Paid:-</label>
				<label><?php echo ( true == valStr( $strAmount ) && 'NULL' != $strAmount ) ? $strAmount . ' <b>Rs</b>' : ''; ?></label>
			</div>
			<div style="clear: both;"></div>
			<hr/>
			<div class="left_div">
				<label>Notes:-</label>
				<div>
					This is the content of the note so please read each and every item mentioned here.
				</div>
			</div>
			<div style="clear: both;"></div>
		</div>
		
		<div>&nbsp;</div>
		<div>&nbsp;</div>
	</div>
</div>
<div style="text-align: center; padding-top: 15px;" id="buttons">
	<input type="button" value="Print" name="print_doc" onclick="PrintDoc();" />
	<input type="button" name="print_preview" value="Print Preview" onclick="PrintPreview();" />
	<a style="color: black;" href="modules.php?file=old_case_papers&mid=<? echo $mid;?>&smid=<? echo $smid;?>" ><input type="button" value="Search New Patient." name="cancel" /></a>
</div>
<div style="text-align: center; padding-top: 15px;" id="operation_buttons">
	<a style="color: black;" href="modules.php?file=case_papers&mid=<? echo $mid;?>&smid=<? echo $smid;?>" ><input type="button" value="Create New Case Paper" name="add_new" /></a>
	<a style="color: black;" href="modules.php?file=view_case_papers&type=view&mid=<? echo $mid;?>&smid=<? echo $smid;?>" ><input type="button" value="View Case Papers" name="cancel" /></a>
</div>

<script type="text/javascript">

/*--This JavaScript method for Print command--*/

function PrintDoc() {
	var toPrint = document.getElementById('print_area');
	var popupWin = window.open('', '_blank', 'width=650,height=350,location=no,left=200px');

	popupWin.document.open();
	popupWin.document.write('<html><title>::Preview::</title><link rel="stylesheet" type="text/css" href="css/printing.css" /></head><body onload="window.print()">')
	popupWin.document.write( toPrint.innerHTML );
	popupWin.document.write('</html>');
	popupWin.document.close();
}

/*--This JavaScript method for Print Preview command--*/
function PrintPreview() {
	var toPrint = document.getElementById('print_area');
	var popupWin = window.open('', '_blank', 'width=650,height=350,location=no,left=200px');

	popupWin.document.open();
	popupWin.document.write('<html><title>::Print Preview::</title><link rel="stylesheet" type="text/css" href="css/printing.css" media="screen"/></head><body">')
	popupWin.document.write( toPrint.innerHTML );
	popupWin.document.write('</html>');
	popupWin.document.close();
}
</script>